import React, { PureComponent } from 'react'

class Home extends PureComponent {

  // 即将渲染时间 beginTime
  UNSAFE_componentWillMount() {
    this.beginTime = Date.now()
  }

  render() {
    return (
      <h2>Home</h2>
    )
  }

  // 渲染完成的时间 endTime
  componentDidMount() {
    this.endTime = Date.now()
    const interval = this.endTime - this.beginTime
    console.log(`渲染时间: ${interval}`)
  }
}

class About extends PureComponent {
  render() {
    return (
      <h2>About</h2>
    )
  }
}

export default class App extends PureComponent {
  render() {
    return (
      <div>
        <Home/>
        <About/>
      </div>
    )
  }
}
